-
Notifications
You must be signed in to change notification settings - Fork 79
resolve issue 319, handling test method name for Parameterized tests #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolve issue 319, handling test method name for Parameterized tests #333
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. This seems okay, but I've a couple of questions:
- How does Gradle and/or Maven report this in their log files? We should be compatible with that, since those are widely used tools, and the XML files are sucked into CI runners to display results.
- Can we please have a test for this? Without one, we're likely to regress this output as we continue to work in this area.
|
We recently landed #351. Could you please LMK if this addressed your issue, or whether this PR still needs to be landed. |
Hey @shs96c, apologies for being so slow. @mattnworb brought this back to my attention. To answer your previous question - the intent of this PR is to reach compatibility with what maven does (at least to the best of my knowledge), specifically for Parameterized Tests. I'll work on adding a test this per your suggestion - thank you for the reminder and follow-up @shs96c! |
Yes #351 was done specifically to handle nesting and kept the previous behavior for parameterized tests alone on purpose for the XML because we wanted to match the behavior of gradle/maven in terms of grouping by class and I wanted the keep the changes focused. Technically one can specify a name value to the annotation to fix this but it's less than ideal behavior when one doesn't do that. The scenarios are:
Then have something like: What's the desired behavior here? |
|
For reference here are the XML formats for the same parameterized test class in bazel, gradle, and maven (when no name is specified in the annotation): BAZEL The main differences include the bazel XML having an outer bazel [index] parameterName=value |
|
After looking into this more, repeated and parameterized tests are using the default naming scheme defined in the junit5 code. I'm not sure the code should override that by default. There's multiple ways to override the default naming behavior including doing things like creating your own NameFormatters and registering yours to override the default ones. Specifically for ParameterizedTests It's probably just easier to go ahead and add the following to your .bazelrc to test: Which would make the output go from: See https://docs.junit.org/current/user-guide/#writing-tests-display-names for more details. |
|
Cool, thank you @christianladam! Taking a look. |
|
@christianladam - using |
Attempts to resolve #319
checks for the ordinal (in parameterized tests), and this case maps each test case to the method name and wraps each of these in their own test suite so the tests show up with each parameterized test as test case, and the method has a test suite.
Basically the hierarchy (for parameterized tests)
Test Class (also a test suiteA)
Test case/method
[1] params=...
[2] params=....